package n08.first;

import java.util.Arrays;
import java.util.Comparator;

public class N02 {
	public static final Comparator<Student> sortByHeight=new Comparator<Student>() {
		@Override
		public int compare(Student o1, Student o2) {
			return Double.compare(o1.getHeight(), o2.getHeight());
		}
	};

	public static void main(String[] args) {
		Student[]a= {
				new Student("20240108", "张三", 21, 1.75),
				new Student("20240105", "李四", 19, 1.95),
				new Student("20240101", "王五", 20, 1.85),
		};
		//(1)按Student类Comparable默认的方法进行排序，默认按年龄排序
		System.out.println("按身高排序~");
		Arrays.sort(a, sortByHeight); 
		for (Student student : a) {
			System.out.println(student);
		}

	}

}
